<template>
	<view>
		<head-box></head-box>
		<view class="page_con">
			<view class="banner">
				<image class="_img" src="/static/img/qyrz_banner.png" mode="widthFix"></image>
			</view>
			<view class="quntuanListPage-main-header">
				<div class="quntuanListPage-main-title">企业认证</div>
			</view>
			<view class="personalInfor-page-main">
				<view class="personalInfor-page-main-box">
					<view class="_main-item">
						<view class="_main-item-chunk _main-item-label"><text>企业名称</text><text class="xing">*</text></view>
						<view class="_main-item-chunk _main-item-val">
							 <input cursorSpacing="10" class="_main-item-val-input" maxlength="30"  v-model="usercomname"  type="text" placeholder="企业名称"/>
						</view>
					</view>
					<view class="_main-item">
						<view class="_main-item-chunk _main-item-label"><text>信用代码</text><text class="xing">*</text></view>
						<view class="_main-item-chunk _main-item-val">
							 <input cursorSpacing="10" class="_main-item-val-input" maxlength="18"  v-model="usercomcreditcode"  type="text" placeholder="企业统一信用代码"/>
						</view>
					</view>
				</view>
			</view>
			<view class="btn" v-if="pd">
				<button type="primary" @click="onGpapply">一键认证</button>
			</view>
		</view>
		<tabs-box></tabs-box>
	</view>
</template>

<script>
	import { addgpUsercom , getgpUsercom } from '@/api/usercom';
	export default {
		data() {
			return {
				usercomname:"",//企业名称
				usercomcreditcode:"",//信用代码
				pd:true,
			};
		},
		computed: {
		},
		onLoad() {
			if(!uni.getStorageSync("token"))
			{
				uni.navigateTo({
					url:"../login/login"
				})
				return;
			}
      //企业认证信查询
			getgpUsercom().then(res => {
					const {success,result:{usercomCreditcode,usercomName}} = res
					if(success)
					{
						this.usercomcreditcode = usercomCreditcode;
						this.usercomname = usercomName;
						this.pd = false;
					}
				});
		},
    onShow(){
      // #ifdef H5
      console.log('分享')
      this.$wxSetShare()
      // #endif
    },
		methods: {
		  //一键认证
			onGpapply()
			{
				if(this.usercomname.length < 5)
				{
					this.$api.msg('请输入正确的企业名称');
					return;
				}

				if(this.usercomcreditcode.length != 18)
				{
					this.$api.msg('请输入正确的企业统一信用代码');
					return;
				}

				const params ={"createBy":"","createTime":"","id":"","updateBy":"","updateTime":"","userId":"","usercomAddress":"","usercomBusscope":"","usercomCreditcode":this.usercomcreditcode,"usercomLegalname":"","usercomName":this.usercomname,"usercomRegnum":"","usercomResult":"","usercomStatus":"","usercomType":""};
				addgpUsercom(params).then(res => {
					if(res.success)
					{
						this.$api.msg('认证成功');
						setTimeout(() => {
							uni.navigateBack();
						}, 1000);
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	.container{
		box-sizing:border-box;
		height: 100vh;
	}
	.page_con{
		padding: 30rpx;
	}
	.banner
	{
		width:100%;
		._img{
			width:100%;
			border-radius:10rpx;
		}
	}
	.quntuanListPage-main-header{
		margin-top: 30rpx;
		.quntuanListPage-main-title{
			font-size: 32rpx;
			color: #333;
			font-weight: 600;
			border-left: 6rpx solid #0071fc;
			background-image:linear-gradient(left, #eff6ff, #ffffff);
			padding-left: 20rpx;
		}
	}

	.personalInfor-page-main{
		width: 100%;
		margin-top: 40rpx;
		box-sizing: border-box;
		.personalInfor-page-main-box{
			width: 100%;
			margin-bottom: 40rpx;
			._main-item{
				// height: 86rpx;
				border-bottom: 1px solid rgba(200,199,204,0.5);
				display: flex;
				flex-wrap: nowrap;
				justify-content: space-between;
				align-items: center;
				font-size: 30rpx;
				._main-item-chunk{
					color: #000;
					line-height: 84rpx;
				}
				._main-item-label{
					width: 30%;
				}
				._main-item-val{
					width: 70%;
					display: flex;
					flex-wrap: nowrap;
					justify-content: flex-end;
					align-items: center;
					button{
						background-color: #dd524d;
						color: #FFFFFF;
					}
					._main-item-val-head{
						width: 48rpx;
						height: 48rpx;
						border-radius: 50%;
						display: flex;
						.head-img{
							width: 100%;
							height: 100%;
							border-radius: 50%;
						}
					}
					._main-item-val-input{
						width: 100%;
						text-align:right;
						display: flex;
						margin-right: 10rpx;
						._main-item-val-input-text{
							display: flex;
							flex-wrap: nowrap;
							align-items: center;
						}
						.drop-dowm-img{
							width: 30rpx;
							height: 30rpx;
							margin-left: 10rpx;
							transform: rotateZ(270deg);
						}
					}
					.drop-dowm-img{
						width: 30rpx;
						height: 30rpx;
						margin-left: 10rpx;
						transform: rotateZ(270deg);
					}
				}
			}
		}
	}
	.xing
	{
		color: #ff0000;
		margin-left: 10rpx;
	}
</style>
